﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Download : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {   string sql = "select * from Download_Type";
        rptDownload.DataSource = DataAccess.GetDataTable(sql, null);
        rptDownload.DataBind();
        downloadBind();
        if (IsPostBack)
        {
            judge();
        }
      
    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        judge();
    }
    protected void judge()
    {
        if (Request.QueryString["dowType"].ToString().Trim() != null && Request.QueryString["dowType"].ToString().Trim() != "")
        {
            dowTypeBind(Request.QueryString["dowType"].ToString().Trim());
        }
        else
        {
            downloadBind();
        }
    }
  
    protected void downloadBind()
    {
        string sql1 = "select * from Download_Info where dowIsShow=1 and dowOntop=0 order by dowUpdateTime desc";
        string sql2 = "select * from Download_Info where dowIsShow=1 and dowOntop=1 order by dowUpdateTime desc";
        DataTable dt1 = DataAccess.GetDataTable(sql1,null);
        DataTable dt2 = DataAccess.GetDataTable(sql2,null);
        dt2.Merge(dt1);
        lvDownload.DataSource = dt2;
        lvDownload.DataBind();
        lblTitleTop.Text = "所有文件";
    }
    protected void dowTypeBind(string downType)
    {
        string sql1 = "select * from Download_Info where dowIsShow=1 and dowOntop=0 and dowType='" + downType + "' order by dowUpdateTime desc";
        string sql2 = "select * from Download_Info where dowIsShow=1 and dowOntop=1 and dowType='" + downType + "' order by dowUpdateTime desc";
        DataTable dt1 = DataAccess.GetDataTable(sql1, null);
        DataTable dt2 = DataAccess.GetDataTable(sql2, null);
        dt2.Merge(dt1);
        lvDownload.DataSource = dt2;
        lvDownload.DataBind();
        lblTitleTop.Text = downType;
    }
}